﻿@{
    Layout = null;
    CJCMS.Application.CategoryManager ca = new CJCMS.Application.CategoryManager();
    IList<CJCMS.Contracts.DTO.Category.CategoryInfo> clist = ca.FetchByPCategoryId("d345e5d2-92c0-488b-b67b-58d51baadf0a");
}

<link href="@Url.Content("~/Content/ForAdmin/css/uniform.default.css")" rel="stylesheet" type="text/css"/>



<script type="text/javascript" src="@Url.Content("~/Content/ForAdmin/js/jquery.dataTables.js")"></script>

<script type="text/javascript" src="@Url.Content("~/Content/ForAdmin/js/DT_bootstrap.js")"></script>

<div class="container-fluid">
<div class="row-fluid">

					<div class="span12">

						<!-- BEGIN PAGE TITLE & BREADCRUMB-->

						<h3 class="page-title">

							数据字典管理 <small></small>

						</h3>

						<ul class="breadcrumb">

							<li>

								<i class="icon-home"></i>

								<a href="/Admin/Index">操作中心面板</a> 

								<i class="icon-angle-right"></i>

							</li>

							<li>

								<a href="#">数据字典管理</a>

								<i class="icon-angle-right"></i>

							</li>

							<li><a href="#">数据字典</a></li>

						</ul>

						<!-- END PAGE TITLE & BREADCRUMB-->

					</div>

				</div>

<div class="row-fluid">

					<div class="span12">

						<!-- BEGIN EXAMPLE TABLE PORTLET-->

						<div class="portlet box blue">

							<div class="portlet-title">

								<div class="caption"><i class="icon-globe"></i>数据字典</div>

								

							</div>

							<div class="portlet-body">

								<div class="" role="grid">
                                   <div class="row-fluid">
                                       </div>
                                   </div>
                                   <table class="table table-striped table-bordered table-hover" id="sample_1">
									    <thead>
										<tr>
											<th></th>
											<th></th>
											<th></th>
											<th></th>                                                                                         <th></th>
										</tr>
									</thead>
									    <tbody></tbody>
								    </table>
						        </div>

						<!-- END EXAMPLE TABLE PORTLET-->

					</div>

				</div>
    </div>

<script>

    var tbl = $('#sample_1').dataTable({
        "oLanguage": {
            "sSearch": "搜索:",
            "sLengthMenu": "每页显示 _MENU_ 条记录",
            "sZeroRecords": "Nothing found - 没有记录",
            "sInfo": "显示第  _START_ 条到第  _END_ 条记录,一共  _TOTAL_ 条记录",
            "sInfoEmpty": "显示0条记录",
            "oPaginate": {
                "sPrevious": " 上一页 ",
                "sNext": " 下一页 ",
            }
        },
        "iDisplayLength": 10,
        "sPaginationType": "bootstrap",
        "bProcessing": true,
        "bLengthChange": false,
        "bSort": false,
        'bPaginate': true,  //是否分页。
        "bServerSide": true,
        "sAjaxSource": "/Admin/GetCategoryList/",//+ $('#category').val(),
        "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
        "aoColumns": [
                       
                        { "sTitle": "名称", "mData": "CategoryName"},
                        { "sTitle": "排序", "mData": "SortNum" },
                        {
                            "sTitle": "显示图标",
                            "mData": "IconName",
                            "fnRender": function (obj) {
                                //alert(obj.aData["Id"]);
                                return '<i class="' + obj.aData["IconName"] + '"></i>';
                            }
                        },
                        { "sTitle": "附加信息", "mData": "ExInfo", }
                        ,
                        { "sTitle": "状态", "mData": "Status", }
                        
        ]
        //"aaData":  //aaData此属性不能改名，DataTable插件使用就是使用这个属性进行数据表的填充，丫这个属性坑了爹好长时间。
        //    [{ "Id": "b13a32ad-1966-443e-aa85-5875cc46e79a", "Title": "产品1", "Body": "1111111111", "Created": "\/Date(1375509334000)\/", "CategoryId": "e1816e33-8bfb-dac3-4e12-5a49030fa692", "ImgUrl": "../upload/images/20130803/201308031355280612.jpg", "IsDisplay": "1", "Lang": "2" }]
    });

    $('#category').change(function () {
        ResetTableData();
    });

    $('#sample_editable_1_new').click(function () {
        Ajax_Location('/Admin/AddCategory');
    });

    $('#deletea').click(function () {
        jQuery("#sample_1 .checkboxes").each(function (e) {
            if ($(this).attr("checked") == "checked") {
                $.ajax({
                    type: 'POST',
                    url: "/Admin/DeleteCategory/" + $(this).val(),
                    success: function (data) {
                        ResetTableData();
                        $.gritter.add({
                            title: '提示信息',
                            text: data,
                        });
                    },
                    error: function (data) {
                        $.gritter.add({
                            title: '提示信息',
                            text: data,
                        });
                    }
                });
            }
        });
    });

    $('#sample_1 .group-checkable').change(function () {
        var set = jQuery(this).attr("data-set");
        var checked = jQuery(this).is(":checked");
        jQuery(set).each(function () {
            if (checked) {
                $(this).attr("checked", true);
                $(this).parent().attr("class", "checked");
            } else {
                $(this).attr("checked", false);
                $(this).parent().attr("class", "");
            }
        });
        jQuery.uniform.update(set);
    });

    //jQuery('#sample_1_wrapper .dataTables_filter input').addClass("m-wrap medium"); // modify table search input
    //jQuery('#sample_1_wrapper .dataTables_length select').addClass("m-wrap small"); // modify table per page dropdown
    //jQuery('#sample_1_wrapper .dataTables_length select').select2(); // initialzie select2 dropdown
    function ResetTableData() {
        var oSettings = tbl.fnSettings();
        //alert(tbl);
        //oSettings.sAjaxSource = "/Admin/GetCategoryList/" + $('#category').val();
        //alert(oSettings.sAjaxSource);
        tbl.fnClearTable();
        tbl.fnDraw(oSettings);
    }
</script>